package com.nginx.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nginx.web.domain.PageQo;
import com.nginx.web.entity.ConfInfo;
import com.nginx.web.service.impl.ConfInfoServiceImpl;
import com.nginx.web.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "conf配置")
@RequestMapping("/confInfo")
@RestController
public class ConfInfoController {

    @Autowired
    private ConfInfoServiceImpl confInfoService;

    @PostMapping("/readConfInfo")
    @ApiOperation(value="读取nginx文件")
    public Result readConfInfo(){
        confInfoService.readConfInfo();
        return Result.success();
    }

    @PostMapping("/writeConfInfo")
    @ApiOperation(value="写入nginx文件")
    public Result writeConfInfo(){
        confInfoService.writeConfInfo();
        return Result.success();
    }

    @PostMapping("/listConfInfo")
    @ApiOperation(value="查询nginx配置")
    public Result listConfInfo(PageQo pageQo){
        Page<ConfInfo> page = confInfoService.listConfInfo(pageQo);
        return Result.success(page);
    }

    @PostMapping("/updateConfInfo")
    @ApiOperation(value="修改nginx配置")
    public Result updateConfInfo(ConfInfo confInfo){
        confInfoService.updateConfInfo(confInfo);
        return Result.success();
    }

}
